package com.hctrl.mybatis.result;

/**
 * @author yzr
 * @date   2021/09/09
 * @description 对象返回格式
 **/
public class CommonResult<T> extends BaseResult {

    private static final long serialVersionUID = -8357618384041486871L;

    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> CommonResult<T> buildData(T data){
        CommonResult<T> result = new CommonResult<>();
        result.setData(data);
        result.setSuccess(true);
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getMessage());
        return result;
    }

}
